Fix unpairing IterableDatasetDict preference datasets - #6924
Fix unpairing IterableDatasetDict preference datasets#6924DaoyuanLi2816 wants to merge 1 commit into
Conversation
|
Your diagnosis is right and the one-liner is the correct fix. I checked out the branch and ran it both ways rather than reading the diff, and along the way found a second copy of the same bug twenty lines down that this PR does not fix. Confirming yours first. On The second copy is if isinstance(dataset, DatasetDict):
column_names = dataset[list(dataset.keys())[0]].column_names
else:
column_names = dataset.column_names # IterableDatasetDict -> the same dict
if "chosen" in column_names and "rejected" in column_names:For an It returns the paired dataset and says nothing, which is a worse failure than the one you fixed because there is no signal at all. The function is public, exported at Both functions sit next to each other and share one root cause, so I would fix them together here rather than in a second PR. Your call, and I would not block on it. The test builds its expected rows by zipping Thanks for catching something that only shows up on the streaming path. |
What does this PR do?
Fixes #6877.
unpair_preference_datasethandledDatasetDictseparately but sentIterableDatasetDict.column_names, a split-to-columns mapping, directly toremove_columns. The iterable map therefore retainedchosenandrejected, whose original batch length conflicts with the doubled unpaired output.This change reads the column names from the first split for both dataset-dictionary types and adds regression coverage that materializes the unpaired iterable split.
Validation:
10 passedforTestUnpairPreferenceDatasetgit diff --checkBefore submitting
AI writing disclosure
We welcome the use of AI tools to help with contributions. For transparency and to help us improve our review process, please indicate the level of AI involvement in this PR.
Who can review?
Anyone in the community is free to review the PR once the tests have passed.
Note
Low Risk
Small, targeted fix in preference dataset preprocessing with regression tests; no auth or security impact.
Overview
Fixes #6877 by correcting how
unpair_preference_datasetresolves columns forIterableDatasetDict.Previously only
DatasetDicttook column names from the first split;IterableDatasetDictfell through to the iterable path and passedcolumn_names(a per-split dict) intoremove_columns, sochosen/rejectedwere not dropped and batched unpairing could misalign lengths. The function now treatsDatasetDictandIterableDatasetDictthe same:column_namescomes fromnext(iter(dataset.values())).column_names.Adds
test_unpair_preference_iterable_dataset_dictto assert an iterable split unpairs to the expected rows when materialized.Reviewed by Cursor Bugbot for commit 90c8397. Bugbot is set up for automated code reviews on this repo. Configure here.